package com.yunhe.mybatis.web.deparment;

import com.yunhe.mybatis.dto.Pageable;
import com.yunhe.mybatis.entity.Deparment;
import com.yunhe.mybatis.service.DeparmentService;
import com.yunhe.mybatis.service.UserService;
import com.yunhe.mybatis.service.impl.DeparmentServiceImpl;
import com.yunhe.mybatis.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/deparment/list")
public class ListServlet extends HttpServlet{
    private DeparmentService deparmentService = new DeparmentServiceImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        List<Deparment> list = deparmentService.findAll();
        req.setAttribute("listdeparment",list);

        req.getRequestDispatcher("/WEB-INF/deparment/list.jsp").forward(req,resp);
    }
}
